export default {
    en:"order",
    cn:"订单",
    fields:{
        buyer: {
            type:"object",
            from: {
                model: "user",
                fields: [
                    "id","name"
                ]
            }
        },
        store: {
            type:"object",
            from: {
                model: "store",
                fields: [
                    "id","name"
                ]
            }
        },
        orderGoods: {
            type:"array",
            from: {
                model: "goods",
                fields: [
                    "name",
                    "price"
                ],
                append:{
                    count:{

                    }
                }
            },
        },
        totalAmount: {
            calculate: function (ctx) {
                return ctx.get("goodsAmount") + 10;
            }
        },
        goodsAmount: {
            calculate: function (context) {
                var total = 0;
                var item = context.get("orderGoods");
                for(var i = 0; i < items.length; i++){
                    total += item[i].price;
                }
                return total;
            }
        }
    },

}